package com.augurit.gis.formquery;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import net.sf.json.JSONArray;

import com.augurit.gis.common.dao.CommonDAO;
import com.augurit.gis.common.util.SQLUtil;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComQyxxForm;

public class FormQueryDAO extends CommonDAO {

	public FormQueryDAO() {
	}
	
	@SuppressWarnings("unchecked")
	public List<CaseFormItem> getFormAnnotation(String table_name){

		String sql  = "select * from user_col_comments t where t.table_name='"+table_name+"'";
		System.out.println(sql);
		try {
			return commonSearch(buildSQL(0, 100, sql),com.augurit.gis.common.dao.ConnectionFactory.getMisConnection());
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
	@SuppressWarnings("unchecked")
	@Override
	public List resultSetToList(ResultSet set) throws SQLException {
		List<CaseFormItem> itemList = new ArrayList<CaseFormItem>();
		while(set.next()){
			CaseFormItem item = new CaseFormItem();
			item.setColumnName(set.getString("COLUMN_NAME").trim());
			item.setColumnAnnotation(set.getString(set.findColumn("comments")));
			itemList.add(item);
		}
		return itemList;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List resultSetToList2(ResultSet set) throws SQLException {
		List<QyItem> itemList = new ArrayList<QyItem>();
		while(set.next()){
			QyItem item = new QyItem();
			item.setYwlxr(set.getString("YWLXR").trim());
			item.setYwlxphone(set.getString("YWLXPHONE"));
			itemList.add(item);
		}
		return itemList;
	}
	
	
	
	@SuppressWarnings("unchecked")
	public List<QyItem> getQY(String QYID){
		String sql  = "select * from YW_COM_QYXX t where t.ID="+QYID+"";
		System.out.println(sql);
		try {
			return commonSearch2(sql,com.augurit.gis.common.dao.ConnectionFactory.getMisConnection());
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
		
	}
}
